import { ref } from "vue";

export function usePageModal(
  confirm?: any,
  editCb?: any
): [any, any, (e: any) => void, (e: any) => void] {
  const pageModalRef = ref();
  const defaultInfo = ref({});//回显数据
  // 这是page-content 打开时候调用胡函数
  const changeDialogVisible = () => {
    pageModalRef.value.dialogVisible = true;
    defaultInfo.value = {};
    confirm && confirm();
  };

  // 这是page-content 打开时候调用胡函数
  const handleEdit = (obj: any) => {
    console.log(obj);
    pageModalRef.value.dialogVisible = true;
    defaultInfo.value = obj;
    editCb && editCb(obj);
  };
  return [pageModalRef, defaultInfo, changeDialogVisible, handleEdit];
}
